/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.mappingtable.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import uimigration.WidgetsModel.Event;
import uimigration.mappingtable.BehaviourType;
import uimigration.mappingtable.MappingBehaviourEvent;
import uimigration.mappingtable.MappingtablePackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapping Behaviour Event</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.mappingtable.impl.MappingBehaviourEventImpl#getBehaviorType <em>Behavior Type</em>}</li>
 *   <li>{@link uimigration.mappingtable.impl.MappingBehaviourEventImpl#getEvent <em>Event</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MappingBehaviourEventImpl extends EObjectImpl implements
		MappingBehaviourEvent {
	/**
	 * The default value of the '{@link #getBehaviorType() <em>Behavior Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBehaviorType()
	 * @generated
	 * @ordered
	 */
	protected static final BehaviourType BEHAVIOR_TYPE_EDEFAULT = BehaviourType.RENDER_LITERAL;
	/**
	 * The cached value of the '{@link #getBehaviorType() <em>Behavior Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBehaviorType()
	 * @generated
	 * @ordered
	 */
	protected BehaviourType behaviorType = BEHAVIOR_TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getEvent() <em>Event</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEvent()
	 * @generated
	 * @ordered
	 */
	protected Event event;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MappingBehaviourEventImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return MappingtablePackage.Literals.MAPPING_BEHAVIOUR_EVENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Event getEvent() {
		return event;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEvent(Event newEvent,
			NotificationChain msgs) {
		Event oldEvent = event;
		event = newEvent;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this,
					Notification.SET,
					MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT,
					oldEvent, newEvent);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEvent(Event newEvent) {
		if (newEvent != event) {
			NotificationChain msgs = null;
			if (event != null)
				msgs = ((InternalEObject) event)
						.eInverseRemove(
								this,
								EOPPOSITE_FEATURE_BASE
										- MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT,
								null, msgs);
			if (newEvent != null)
				msgs = ((InternalEObject) newEvent)
						.eInverseAdd(
								this,
								EOPPOSITE_FEATURE_BASE
										- MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT,
								null, msgs);
			msgs = basicSetEvent(newEvent, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT,
					newEvent, newEvent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BehaviourType getBehaviorType() {
		return behaviorType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBehaviorType(BehaviourType newBehaviorType) {
		BehaviourType oldBehaviorType = behaviorType;
		behaviorType = newBehaviorType == null ? BEHAVIOR_TYPE_EDEFAULT
				: newBehaviorType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__BEHAVIOR_TYPE,
					oldBehaviorType, behaviorType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT:
			return basicSetEvent(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__BEHAVIOR_TYPE:
			return getBehaviorType();
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT:
			return getEvent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__BEHAVIOR_TYPE:
			setBehaviorType((BehaviourType) newValue);
			return;
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT:
			setEvent((Event) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__BEHAVIOR_TYPE:
			setBehaviorType(BEHAVIOR_TYPE_EDEFAULT);
			return;
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT:
			setEvent((Event) null);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__BEHAVIOR_TYPE:
			return behaviorType != BEHAVIOR_TYPE_EDEFAULT;
		case MappingtablePackage.MAPPING_BEHAVIOUR_EVENT__EVENT:
			return event != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (behaviorType: ");
		result.append(behaviorType);
		result.append(')');
		return result.toString();
	}

} //MappingBehaviourEventImpl
